import request from '@/utils/request'

/**
 * 分页查询角色信息
 *
 * @param {*} query
 */
export function fetchList(query) {
  return request({
    url: '/base/auth/role/list',
    method: 'get',
    params: query
  })
}

/**
 * 新增角色信息
 * @param {*} baseRole
 */
export function createAuthRole(baseRole) {
  return request({
    url: '/base/auth/role/create',
    method: 'post',
    data: baseRole
  })
}

/**
 * 更新角色信息
 * @param {*} baseRole
 */
export function updateAuthRole(baseRole) {
  return request({
    url: '/base/auth/role/update',
    method: 'post',
    data: baseRole
  })
}

/**
 * 删除角色信息
 * @param {*} roleCode
 */
export function deleteAuthRole(roleId) {
  return request({
    url: '/base/auth/role/delete',
    method: 'post',
    params: { roleId }
  })
}

/**
 * 角色分配资源权限
 * @param {*} roleId
 * @param {*} resIds
 */
export function updateRoleResAuth(roleId, resIds) {
  return request({
    url: 'base/auth/role/auth',
    method: 'post',
    params: { roleId },
    data: resIds
  })
}

/**
 * 获取资源树信息
 */
export function getResourceTree() {
  return request({
    url: '/base/auth/role/res/tree',
    method: 'get'
  })
}

/**
 * 获取角色对应资源信息
 * @param {*} roleId
 */
export function getRoleResList(roleId) {
  return request({
    url: '/base/auth/role/res/list',
    method: 'get',
    params: { roleId }
  })
}
